﻿@using ECG.Common
@using ECG.WebUI.CustomHelpers
@using ECG.WebUI
@model ViewProductDetailDto
@{
    ViewBag.Title = string.IsNullOrEmpty(Model.MetaTitle) ? Model.Name : Model.MetaTitle;
    ViewBag.Description = string.IsNullOrEmpty(Model.MetaDescription) ? Model.Name : Model.MetaDescription;
    ViewBag.keywords = string.IsNullOrEmpty(Model.MetaKeyword) ? Model.Name : Model.MetaKeyword;
    Layout = "~/Views/Shared/_LayoutHideCate.cshtml";
    var fbFanUrl = ECG.WebUI.CustomHelpers.FunctionHelpers.returnConfig("FacebookFanpageUrl");
    var fbcode = ECG.WebUI.CustomHelpers.FunctionHelpers.returnConfig("FacebookCode");
    //var url = FunctionHelpers.GetFullUrl();
    var sizeList = (List<ProductSizeListByPidDto>)ViewBag.SizeList;
    var colorList = ((IEnumerable<ProductImageHasColorInfoDto>)ViewBag.ColorList).Select(i => new { i.ColorId, i.ColorName, i.Code })
                    .Distinct()
                    .Where(i => !i.ColorId.Equals("-1"))
                    .ToList();
    var itemColMultiple = colorList.Select(i => new { i.ColorId, i.ColorName, i.Code }).FirstOrDefault(i => i.ColorId.Equals("0"));
    var productStatus = string.Empty;
    switch (Model.ProductStatus)
    {
        case "conhang":
            productStatus = "<span class='haspd'>Còn hàng</span>";
            break;
        case "goihang":
            productStatus = "<span class='callpd'>Gọi hàng</span>"; break;
        case "hethang":
            productStatus = "<span class='overpd'>Hết hàng</span>"; break;
        case "onlyOnline":
            productStatus = "<span class='onlyOlpd'>Chỉ bán Online</span>"; break;
        default:
            productStatus = "<span class='haspd'>Còn hàng</span>";
            break;
    }
}

<div class="layout-width">
    @Html.Action("DirectionCategory", "Category", new { categoryId = ViewBag.CateId })
    <div class="p-detail-wrap clearfix">
        <div class="pd-bg">
            <div class="p-detail-top-left fl">
                @using (Html.BeginForm("Index", "ProductDetail", FormMethod.Post))
                {
                    <div class="pDetailPadding20">
                        <div class="pDetail-header">
                            <h1>@Model.Name</h1>
                            <div class="pd-social-like">
                                <ul class="socialShare ul clearfix">
                                    <li>
                                        <div id="fb-root"></div>
                                        <div class="fb-like" data-href="@fbFanUrl" data-layout="button_count" data-action="like" data-show-faces="false" data-share="false"></div>
                                    </li>
                                    <li>
                                        <g:plusone size="medium" annotation="none"></g:plusone>
                                    </li>
                                    <li></li>
                                </ul>
                            </div>
                        </div>
                        <div class="pDetail-info clearfix">
                            <div class="pDetail-img fl">
                                <!--PRODUCT DETAIL IMG-->
                                @{
                    var ListimgName = Model.ImagePath.Split('/');
                    var imgName = ListimgName[ListimgName.Length - 1];
                    var pathName = "";
                    for (int i = 0; i < ListimgName.Length - 1; i++)
                    {
                        pathName += "/" + ListimgName[i];
                    }
                                }
                                @Html.Action("ProductImageDetail", "ProductDetail", new { productId = Model.Id, ColorId = "", ProductImagePathFirst = pathName, ProductImageNameFirst = imgName })
                                <!--END PRODUCT DETAIL IMG-->
                            </div>
                            <div class="pDetail-infotext fl">
                                <div class="infotextRightTop clearfix">
                                    <div class="infotext-left fl">
                                        <p>
                                            Mã Sản Phẩm
                                            @Html.Hidden("productId", Model.Id)
                                            @Html.Hidden("productIdRoot", Model.Id)
                                            @Html.Hidden("productImagePath", Model.ImagePath)
                                            @Html.Hidden("rootPriceProduct", Model.Price)
                                            @Html.Hidden("promotionPrice", Model.PromotionPrice)
                                            <input type="hidden" name="productName" id="productName" value="@Model.Name" />
                                            @Html.Hidden("productBarcode", Model.Barcode)
                                            @Html.Hidden("productStatus", Model.ProductStatus)
                                            @Html.Hidden("productColor")
                                            @Html.Hidden("productColorCode")
                                            @Html.Hidden("productSizeId")
                                            @Html.Hidden("productSizeName")
                                            @Html.Hidden("productSizePrice")
                                            @Html.Hidden("promotionPercent", Model.DiscountPercentage)
                                            @Html.Hidden("decreasePrice", Model.DiscountAmount)
                                            @Html.Hidden("providerName", Model.ProviderName)
                                            @Html.Hidden("categoryId", Model.CategoryId)
                                            @Html.Hidden("categoryName", Model.CategoryName)

                                        </p>
                                        @if (!string.IsNullOrEmpty(Model.ProviderName))
                                        {
                                            <p>
                                                Hãng sản xuất
                                            </p>
                                        }
                                        @if (Model.PromotionPrice > 0)
                                        {
                                            <p class="pd-priceLast">
                                                Giá
                                            </p>
                                        }
                                        else
                                        {
                                            <p>
                                                Giá
                                            </p>
                                        }

                                        <p>
                                            Tình Trạng
                                        </p>
                                        @if (sizeList.Any())
                                        {
                                            <p>
                                                Size
                                            </p>
                                        }
                                        @if (colorList.Any())
                                        {
                                            <p>
                                                Mầu sắc
                                            </p>
                                        }
                                        <p>
                                            Đánh Giá
                                        </p>
                                        <p class="pd-quan">
                                            Số Lượng
                                        </p>
                                    </div>
                                    <div class="infotext-right fl">
                                        <p class="pd-code">
                                            @Model.Barcode
                                        </p>
                                        <p>
                                            <a href="#">@Model.ProviderName </a>
                                        </p>
                                        @if (Model.PromotionPrice > 0)
                                        {
                                            <p class="pd-price">
                                                @Model.PromotionPrice.ToString("#,###") đ
                                                <div class="p-price-promo">Giá trước đây <span class="p-priceOld">@Model.Price.ToString("#,###") đ</span> , Tiết kiệm <b>@Model.DiscountPercentage.ToString("##")%</b></div>
                                            </p>
                                        }
                                        else
                                        {
                                            <p class="pd-price">
                                                @Model.Price.ToString("#,###") đ
                                            </p>
                                        }

                                        <p class="pd-sttus">
                                            @Html.Raw(productStatus)
                                        </p>
                                        @if (sizeList.Any())
                                        {
                                            var itemFirstSize = sizeList.FirstOrDefault();
                                            <p class="pd-size clearfix">
                                                @if (itemFirstSize != null)
                                                {
                                                    var sizePromotionPrice = Model.GetPricePromotionBySizePrice(itemFirstSize.SizePrice);
                                                    <a href="javascript:void(0);" rel="nofollow" title="@itemFirstSize.SizeName" sizepromotionpriceshow="@sizePromotionPrice.ToString("#,###")" sizepriceshow="@itemFirstSize.SizePrice.ToString("#,###")" sizepromotionprice="@sizePromotionPrice" sizeid="@itemFirstSize.SizeId" sizeprice="@itemFirstSize.SizePrice">@itemFirstSize.Code</a>
                                                }
                                                @foreach (var item in sizeList.Where(item => item != sizeList.First()))
                                                {
                                                    var sizePromotionPrice = Model.GetPricePromotionBySizePrice(item.SizePrice);
                                                    <a href="javascript:void(0);" rel="nofollow" title="@item.SizeName" sizepromotionpriceshow="@sizePromotionPrice.ToString("#,###")" sizepriceshow="@item.SizePrice.ToString("#,###")" sizepromotionprice="@sizePromotionPrice" sizeid="@item.SizeId" sizeprice="@item.SizePrice">@item.Code</a>
                                                }
                                            </p>
                                        }
                                        @if (colorList.Any())
                                        {
                                            <p class="pd-Color clearfix">
                                                @if (itemColMultiple != null)
                                                {
                                                    <a href="javascript:void(0);" rel="nofollow" style="background-color: @itemColMultiple.Code;" colorcode="@itemColMultiple.Code" colorname="@itemColMultiple.ColorName" id="color-id-@itemColMultiple.ColorId" title="@itemColMultiple.ColorName">
                                                    </a>
                                                }

                                                @foreach (var item in colorList.Where(item => !item.ColorId.Equals("0")))
                                                {
                                                    <a href="javascript:void(0);" rel="nofollow" style="background-color: @item.Code;" colorcode="@item.Code" colorname="@item.ColorName" id="color-id-@item.ColorId" idcolor="@item.ColorId" title="@item.ColorName">
                                                    </a>
                                                }
                                            </p>
                                        }
                                        <div style="line-height: 13px; margin: 5px 0px;">
                                            @{
                                        string StarPercent = "0";
                                        if (Model.AverageRate > 0)
                                        {
                                            StarPercent = (Convert.ToDouble(Model.AverageRate) * 100 / 5).ToString("#.#").Replace(',', '.');
                                        }
                                            }
                                            <span class="itm-ratStars inlineBlocka"><span style="width: @StarPercent%;" class="itm-ratStars itm-ratRating"></span></span>
                                        </div>
                                        <div class="box-quan">
                                            <input type="text" width="28" height="19" maxlength="2" value="1" name="productQuantity" id="productQuantity" />
                                            <a href="javascript:void(0);" class="quan-top" rel="nofollow"></a>
                                            <a href="javascript:void(0);" class="quan-bottom" rel="nofollow"></a>
                                        </div>
                                    </div>
                                </div>
                                <div class="infotextRightBottom">
                                    <div class="pd-detailproperty">
                                        <ul class="tab-property ul">
                                            @if (!string.IsNullOrEmpty(Model.CustomInfoFirst))
                                            {
                                                <li>
                                                    <span>@Model.CustomInfoFirst</span>
                                                </li>
                                            }
                                            @if (!string.IsNullOrEmpty(Model.CustomInfoSecond))
                                            {
                                                <li>
                                                    <span>@Model.CustomInfoSecond</span>
                                                </li>
                                            }
                                            @if (!string.IsNullOrEmpty(Model.CustomInfoThird))
                                            {
                                                <li>
                                                    <span>@Model.CustomInfoThird</span>
                                                </li>
                                            }

                                        </ul>
                                    </div>
                                    <div class="pd-detail-other">
                                        <a href="/d/Huong-dan-dat-mua-hang-n96399191.html" rel="nofollow" class="icon-hdmh">
                                            <i></i>
                                            Hướng dẫn mua hàng
                                        </a>
                                        <a href="#" rel="nofollow" class="p-rate">
                                            <i></i>
                                            Đánh giá sản phẩm
                                        </a>
                                        <a href="#" rel="nofollow" class="add-wishlist">
                                            <i></i>
                                            Thêm vào ưa thích
                                        </a>
                                    </div>
                                    <div class="pd-detail clearfix">
                                        @if (!Model.ProductStatus.Equals("hethang"))
                                        {
                                            <input type="submit" class="btnGioHang fl" />
                                            <input type="button" class="btnMuaNgay fl" />
                                        }
                                        else
                                        {
                                            <input type="button" class="btnHetHang" />
                                        }
                                    </div>
                                    <div class="pd-promotionInfo">
                                        <p>
                                            @if (Model.PromotionPrice > 0)
                                            {
                                                @Model.DiscountInfo
                                            }
                                            else
                                            {
                                                var textPromotion = ConfigInfo.GetByKey("productDetail-text-promotion");
                                                if (!string.IsNullOrEmpty(textPromotion))
                                                {
                                                    @Html.Raw(textPromotion)
                                                }
                                                else
                                                {
                                                    @Html.Raw(ConfigInfo.GetByKey("productDetail-text-promotion", "StaticHtml", @"<span>
                                                    <b>Tư vấn: 043 562.7737 - <span style='color: #fd7100;'>0988.388.000</span></b>
                                                </span>", "Đoạn text khuyến mại dưới nút đặt hàng"))
                                                }

                                            }
                                        </p>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                }
            </div>
            <div class="p-detail-top-right fl">
                @{
                    var supportaDetail = ECG.WebUI.ConfigInfo.GetByKey("supportOnline-productdetail");
                }
                @if (!string.IsNullOrEmpty(supportaDetail))
                {
                    @Html.Raw(supportaDetail)
                }
                else
                {
                    @Html.Raw(ECG.WebUI.ConfigInfo.GetByKey("supportOnline-productdetail", "StaticHtml", @"<div class='supportInfo-box'>
                    <div class='sp-info-header'>
                        thông tin hỗ trợ
                    </div>
                    <div class='sp-info-body'>
                        <ul class='ul'>
                            <li>
                                <a title='Tới babo Hà Nội' href='https://maps.google.com/maps?ie=UTF-8&q=BaBo&fb=1&gl=vn&hq=babo&hnear=0x3135ab9bd9861ca1:0xe7887f7b72ca17a9,H%C3%A0+N%E1%BB%99i&cid=7966196611370637473&ei=GTOwUsf3JOy4iAev4oC4Bw&ved=0CMsBEPwSMBA' rel='nofollow' class='iMap'></a>
                                <p>
                                    <strong>Tại Hà Nội</strong>
                                    <br />
                                    Số 11 Tô Vĩnh Diện, Khương Trung, Thanh Xuân, HN
                                </p>
                                <p>
                                    <a href='ymsgr:sendIM?hngiang84&amp;m=Chao ban!' rel='nofollow' style='background: url(http://opi.yahoo.com/online?u=hngiang84&amp;t=5&amp;l=us) 0px 1px no-repeat; padding-left: 17px;'>Mr. Giang</a>
                                    <span>0988.388.000</span>
                                </p>
                            </li>
                            <li>
                                <a href='' title='Tới babo HCM' rel='nofollow' class='iMap'></a>
                                <p>
                                    <strong>Tại HCM</strong>
                                    <br />
                                    61 Trần Minh Quyền, P.10, Q.10, Tp.HCM
                                </p>
                                <p>
                                    <a href='ymsgr:sendIM?hngiang84&amp;m=Chao ban!' rel='nofollow' style='background: url(http://opi.yahoo.com/online?u=hngiang84&amp;t=5&amp;l=us) 0px 1px no-repeat; padding-left: 17px;'>Mr. Giang</a>
                                    <span>0948.91.3838</span>
                                </p>
                            </li>
                        </ul>
                    </div>
                </div><div class='pd-infoText'>
                    <ul class='ul'>
                        <li>
                            <a href='#' rel='nofollow'>100% Hàng chính hãng</a>
                        </li>
                        <li>
                            <a href='#' rel='nofollow'>Thanh toán khi nhận hàng</a>
                        </li>
                        <li>
                            <a href='#' rel='nofollow'>Đổi trả hàng trong 07 ngày</a>
                        </li>
                    </ul>
                </div>", "Thông tin hỗ trợ trong phần chi tiết sản phẩm"));
                }
                <div class="pd-same-box">
                    @Html.Action("ProductConcern", new { categoryId = ViewBag.CateId, ProductDate = Model.CreateDate, ProductId = Model.Id })
                </div>
            </div>
        </div>
    </div>
    <!-- Customers Who Bought This Item Also Bought-->
    @Html.Action("CustomerBought", "ProductDetail")
    <!-- End Customers Who Bought This Item Also Bought-->

    <div class="p-detail-body clearfix">
        <div class="detail-body-left fl">
            <div class="pDetail-headerTab">
                <ul class="ul clearfix">
                    <li class="headerTab-ac">
                        <a href="javascript:void(0);" rel="nofollow">Tổng quan</a>
                    </li>
                    <li>
                        <a href="javascript:void(0);" rel="nofollow" id="productCommentTab">Nhận xét & Bình luận</a>
                    </li>
                    <li>
                        <a href="javascript:void(0);" rel="nofollow">Video về sản phẩm</a>
                    </li>
                </ul>
            </div>
            <div class="pDetail-Content-wrap">
                <div class="pDetail-Content-Item ContentItem-ac">
                    <div class="pd_boxmore clearfix">
                        <h6>
                            Thông số kỹ thuật
                        </h6>
                        <ul>
                            @if (!string.IsNullOrEmpty(Model.CustomInfoFirst))
                            {
                                <li>
                                    <span>@Model.CustomInfoFirst</span>
                                </li>
                            }
                            @if (!string.IsNullOrEmpty(Model.CustomInfoSecond))
                            {
                                <li>
                                    <span>@Model.CustomInfoSecond</span>
                                </li>
                            }
                            @if (!string.IsNullOrEmpty(Model.CustomInfoThird))
                            {
                                <li>
                                    <span>@Model.CustomInfoThird</span>
                                </li>
                            }
                        </ul>
                    </div>
                    @Html.Raw(Model.Description)
                </div>
                <div class="pDetail-Content-Item">
                    @Html.Action("ProductRate", "ProductDetail", new { productId = Model.Id })
                    @Html.Action("ProductComment", "ProductDetail")
                </div>
                <div class="pDetail-Content-Item">
                    Chưa có video nào
                </div>
            </div>
            @Html.Action("TagsByProduct", new { productId = Model.Id })
            @if (!string.IsNullOrEmpty(fbFanUrl) && !string.IsNullOrEmpty(fbcode))
            {
                <div class="pd-fb-cmm">
                    <div class="fb-comments" data-href="@Request.Url" data-width="740" data-numposts="10" data-colorscheme="light"></div>
                </div>
                <div class="pd-fb-box">
                    <div class="fb-like-box" data-href="@fbFanUrl" data-width="740" data-height="200" data-colorscheme="light" data-show-faces="true" data-header="true" data-stream="false" data-show-border="true"></div>
                </div>
            }
        </div>
        <div class="detail-body-right fl">
            <div id="plcSpqt">
                <!--Noi dat cac san pham qua tam -->
            </div>
            @*@Html.Action("ProductDetailRight", "ProductDetail", new { productId = Model.Id })*@
        </div>
    </div>
</div>
@section scripts
{
    <link href="~/Scripts/CloudZoom/cloud-zoom.css" rel="stylesheet" />
    @if (!string.IsNullOrEmpty(fbFanUrl) && !string.IsNullOrEmpty(fbcode))
    {
        @Html.Raw(Server.HtmlDecode(fbcode))
    }
    @Scripts.Render("~/bundles/jqueryval")
    @Scripts.Render("~/bundles/productDetail")

}

@section headerProperty
{
    <meta property="og:image" content="@Model.ImagePath.ImagePathThumbDefault()" itemprop="thumbnailUrl" />
    <meta property="og:title" content="@Model.Name">
    <meta itemprop="description" property="og:description" content="@Model.MetaDescription">
    <meta property="og:url" content="@Request.Url" />
}